package com.me.factory.simplefactory.pizzastore.order;

import com.me.factory.simplefactory.pizzastore.pizza.CheesePizza;
import com.me.factory.simplefactory.pizzastore.pizza.GreekPizza;
import com.me.factory.simplefactory.pizzastore.pizza.PepperPizza;
import com.me.factory.simplefactory.pizzastore.pizza.Pizza;

/**
 * 简单工厂
 */
public class SimpleFactory {
    /**
     * 增加orderType返回对应的Pizza对象
     */
    public Pizza createPizza(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if ("cheese".equals(orderType)) {
           pizza = new CheesePizza();
           pizza.setName("奶酪披萨");
        } else if ("peoper".equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;
    }

    public static Pizza creatPizza2(String orderType) {
        Pizza pizza = null;
        System.out.println("使用简单工厂模式");
        if ("greek".equals(orderType)) {
            pizza = new GreekPizza();
            pizza.setName("希腊披萨");
        } else if ("cheese".equals(orderType)) {
            pizza = new CheesePizza();
            pizza.setName("奶酪披萨");
        } else if ("peoper".equals(orderType)) {
            pizza = new PepperPizza();
            pizza.setName("胡椒披萨");
        }
        return pizza;

    }
}
